// app.js
App({
  onLaunch: function () {
    if (!wx.cloud) {
      console.error('请使用 2.2.3 或以上的基础库以使用云能力');
    } else {
      wx.cloud.init({
        traceUser: true,
      });
    }
    const info = wx.getSystemInfoSync()
    this.globalData.screenWidth = info.screenWidth
    this.globalData.screenHeight = info.screenHeight
    this.globalData.statusBarHeight = info.statusBarHeight 
    // 获取状态栏高度
    this.globalData.statusHeight = info.statusBarHeight
    // 获取屏幕宽度
    this.globalData.screenWidth = info.screenWidth
    // 获取屏幕高度
    this.globalData.screenHeight = info.screenHeight

    this.globalData.statusBarHeight = info.statusBarHeight
    // 胶囊按钮位置信息
    const menuButtonInfo = wx.getMenuButtonBoundingClientRect();

    this.globalData.navBarHeight = (menuButtonInfo.top - info.statusBarHeight) * 2 + menuButtonInfo.height + info.statusBarHeight;
    // 胶囊距右方间距
    this.globalData.menuRight = info.screenWidth - menuButtonInfo.right;
    // 胶囊距底部间距
    this.globalData.menuBotton = menuButtonInfo.top - info.statusBarHeight;
    // 胶囊高度
    this.globalData.menuHeight = menuButtonInfo.height;

    const deviceRadio = info.screenHeight / info.screenWidth
    this.globalData.deviceRadio = deviceRadio
  },
  globalData:{
    screenWidth: 0,
    screenHeight: 0,
    statusBarHeight: 0,
    navBarHeight: 44,// 导航栏高度
    statusHeight: 0, // 状态栏高度
    menuRight: 0, // 胶囊距右方间距（方保持左、右间距一致）
    menuBotton: 0, // 胶囊距底部间距（保持底部间距一致）
    menuHeight: 0, // 胶囊高度（自定义内容可与胶囊高度保证一致）
    deviceRadio: 0,
  }
});
